Skip to content

fix(api): use keyword search for economy datasets in hit testing - #44895

Merged
JohnJyong merged 3 commits into
langgenius:mainfrom
cty-ut:fix/hit-testing-economy-keyword-search
Oct 29, 2026
Merged

JohnJyong merged 3 commits into
langgenius:mainfrom
cty-ut:fix/hit-testing-economy-keyword-search

Conversation

@cty-ut

@cty-ut cty-ut commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Fixes #44894

HitTestingService.retrieve now checks the dataset's indexing technique before choosing the search method. Economy datasets always use keyword search; other datasets still use the requested or configured search_method as before.

This matches DatasetRetrieval (chat apps and workflows) and the console hit-testing page, which already force keyword search for economy datasets. Economy datasets have no vector index, so this also applies when a caller explicitly requests semantic_search.

Tests

Added a parametrized test in test_hit_testing_service.py that checks the retrieval_method passed to RetrievalService.retrieve:

Dataset Requested retrieval_model Expected method
economy none keyword_search
economy semantic_search keyword_search
high_quality none semantic_search

The two economy cases fail without the fix; the high-quality case is a control and passes before and after.

Screenshots

Before After
POST /v1/datasets/<id>/retrieve with only query on an economy dataset returns 400 Default model not found for text-embedding Economy datasets use keyword search

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

@cty-ut
cty-ut requested a review from JohnJyong as a code owner October 27, 2026 12:08
@github-actions github-actions Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 27, 2026
@autofix-ci
autofix-ci Bot requested a review from QuantumGhost as a code owner October 27, 2026 12:11
@autofix-ci
autofix-ci Bot requested a review from a team October 27, 2026 12:11
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 80.00% 80.00% +0.00%
Strict coverage 79.69% 79.69% +0.00%
Typed symbols 76,994 76,999 +5
Untyped symbols 19,322 19,322 0
Modules 3987 3987 0

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.54%. Comparing base (ac0bdd2) to head (8eec70b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #44895   +/-   ##
=======================================
  Coverage   89.54%   89.54%           
=======================================
  Files        6011     6011           
  Lines      377077   377078    +1     
  Branches    76340    76340           
=======================================
+ Hits       337662   337669    +7     
+ Misses      33421    33414    -7     
- Partials     5994     5995    +1     
Flag Coverage Δ
api 89.41% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JohnJyong JohnJyong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete diff and traced the console/Service API entry points, retrieval dispatch, and existing economy-dataset behavior. No issues found.

Validated on this head: 84 targeted tests passed across hit-testing service, retrieval service, and console/Service API controller tests; Ruff check and format check passed. Current backend unit, controller, integration, and Python-style CI checks are green.

@JohnJyong
JohnJyong enabled auto-merge October 28, 2026 16:59
@JohnJyong
JohnJyong added this pull request to the merge queue Oct 29, 2026
Merged via the queue into langgenius:main with commit ac15021 Oct 29, 2026
47 checks passed
@laipz8200 laipz8200 mentioned this pull request Nov 3, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Service API retrieve fails with "Default model not found for text-embedding" on economy knowledge bases

2 participants